package org.mx.service.rocketmq;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

@SuppressWarnings("javadoc")
public class OnewayProducer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("rocket-mq-test1");
        producer.setNamesrvAddr("localhost:9876");
        producer.start();
        for (int i = 0; i < 100; i ++) {
            Message msg = new Message("topic-test1", "oneway",
                    String.format("Hello RocketMQ %d", i).getBytes("utf-8"));
            msg.putUserProperty("id", "" + i);
            producer.sendOneway(msg);
        }
        producer.shutdown();
    }
}
